import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
} from '@nestjs/common';
import { SignService } from './sign.service';
import { CreateSignDto } from './dto/create-sign.dto';
import { PageQuery } from '../../../util/entity/page.entity';
import { Sign } from './entities/sign.entity';
import { UpdateSignDto } from './dto/update-sign.dto';
import { ReqUser } from '../../../common/decorator/user.decorator';

@Controller()
export class SignController {
  constructor(private readonly signService: SignService) {}

  @Post()
  create(@Body() createSignDto: CreateSignDto) {
    return this.signService.create(createSignDto);
  }

  @Post('sign')
  sign(@ReqUser('id') userId: number) {
    return this.signService.sign(userId);
  }

  @Post('list')
  findAll(@Body() pageQuery: PageQuery<Sign>) {
    return this.signService.findAll(pageQuery);
  }

  @Get(':id')
  findOne(@Param('id') id: number) {
    return this.signService.findOne(id);
  }

  @Patch(':id')
  update(@Param('id') id: number, @Body() updateSignDto: UpdateSignDto) {
    return this.signService.update(id, updateSignDto);
  }

  @Delete(':id')
  remove(@Param('id') id: number) {
    return this.signService.remove(id);
  }
}
